{extend name="public/common"}
{block name="style"}
<title>点对点教育VIP学员_学员管理</title>
<link rel="stylesheet" href="__HOME__/css/mui/mui.min.css">
<link rel="stylesheet" href="__HOME__/css/user/leader.css">
<style>
    .search{
        background: #f0eff5;
        padding:2.133vw 4vw;
        border-bottom: 1px solid #f0eff5;
        position: relative;
        z-index:5;
    }
    .search>.searchBox{
        border-radius: 5px;
        height:7.466vw;
        background: #ffffff;
        text-align: center;

    }
    .search>.unBtn{
        display: none;
    }
    /*.search>.searchBox>.searchInput{*/
        /*display: none;*/
    /*}*/
    .search>.searchBox>.searchText{
        display: inline-block;
        font-size:1.4rem;
        color: #999;
        padding-left:6.4vw;
        min-width: 1px;
        height:7.46vw;
        background: url("/DDDeducation/public/home/images/user/search.png") 0 50% no-repeat;
        background-size: 4.8vw 4.8vw;
    }
    .search.isClick{
        background: #ffffff;
        border-bottom: 1px solid #f1f1f1;
        display: flex;
    }
    .search.isClick>.searchBox{
        background: #f0eff5;
        padding-left: 2.66vw;
        width:74vw;
        display: flex;
        align-items: center;
    }
    .search.isClick>.searchBox>.searchText{
        display: inline-block;
    }
    .search.isClick>.searchBox>.searchText>.searchText_c{
        display: none;
    }
    /*.search.isClick .searchInput{*/
        /*background: #f0eff5;*/
        /*display: inline-block;*/
        /*height:6.4vw;*/
        /*width:61.33vw;*/
    /*}*/
    .search.isClick>.unBtn{
        margin-left: 5.33vw;
        display: block;
        box-sizing: border-box;
        width:13.33vw;
        height:7.46vw;
        border-radius: 5px;
        border:1px solid #5d9cec;
        color: #5d9cec;
        text-align: center;
        line-height: 6.93vw;
        font-size: 1.4rem;
    }
    .hidden{
        display: none;
    }
    .none{
        line-height: 10;
        text-align: center;
        font-size: 1.5rem;
        color: #333;
    }
    input[type=color], input[type=date], input[type=datetime-local], input[type=datetime], input[type=email], input[type=month], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=time], input[type=url], input[type=week], select, textarea {
        margin-bottom: 0;
        border: 0 solid rgba(0,0,0,.2);
    }
</style>
{/block}
{block name="body"}
<div class="search isClick">
    <div class="searchBox">
        <div class="searchText"><span class="searchText_c">搜索</span></div>
        <input type="text" class="searchInput" placeholder="姓名" value="">
    </div>
    <div class="unBtn">取消</div>
</div>


<!--搜索返回列表-->
<ul class="result_box hidden">

</ul>

<!--无-->
<div class="none hidden">
    暂无搜索结果...
</div>
{/block}
{block name="script"}
<script src="__HOME__/js/reset.js"></script>
<script src="__HOME__/js/mui.min.js"></script>
<script>
    $('title').text('点对点教育VIP学员_学员管理');
    var id = "{$id}";
    var sear = "";
    if (localStorage.getItem("sear") !="" && localStorage.getItem("sear") !=null){
        sear =localStorage.getItem("sear");
        $(".searchInput").val(sear);
        $(".result_box li").each(function(){
            $(this).remove();
        });
        $.ajax({
            type:"post",
            url:"{:Url('User/search')}",
            data:{
                search:sear,
                id:id
            },
            success:function(data){
                $(".result_box").removeClass("hidden");
                $(".result_box").html('');
                addToList(data)
            }
        });
    }
    onInput();
    //取消输入
    $(".search .unBtn").on("click",function(){
        offInput();
        onInput();
        localStorage.setItem("sear",'');
        var url ='http://mp.csppat.com/DDDeducation/public/index.php/home/user/see';
        window.location.href=url;
    });
    //搜索ajax
    $(".searchInput").on("input",function(){
        var val=$(this).val();
        if(!val)
        {
            $(".result_box").html('');
            return '';
        }

        $.ajax({
            type:"post",
            url:"{:Url('User/search')}",
            data:{
                search:val,
                id:id
            },
            success:function(data){
                localStorage.setItem("sear",val);
                $(".result_box").removeClass("hidden");
                $(".result_box").html('');
                addToList(data)
            }
        });
    });
    //  添加到网页
    function addToList(data) {
        var html = '';
        var lists = data.data;
        var len = lists.length;
        var percent='';
        var percents = '';
        if(len == 0){
            $(".none").removeClass("hidden");
        }else {
            $(".none").addClass("hidden");
            for(var i = 0; i< len;i++){
                var list = lists[i];
                if(list.percent==0){
                    percent = 0
                }else{
                    percent = (list.percent*100).toFixed(1)+'%'
                }
                if(list.percents==0){
                    percents = 0
                }else{
                    percents = (list.percents*100).toFixed(1)+'%'
                }
                if(list.name){
                    list.str = list.name;
                }else{
                    list.str = list.order_id;
                }
                html+='<ul><li>' +
                        '<div class="head">' +
                        '<img src="'+list.headimgurl+'">' +
                        '<span class="name">'+list.str+'</span>' +
                        '<a class="alllog" href="/DDDeducation/public/index.php/home/Journal/personal/openid/'+list.openid+'">总结&nbsp;<i class="fa fa-angle-right" aria-hidden="true"></i></a>' +
                        '<a class="alllogs" href="/DDDeducation/public/index.php/home/Test/testlist/openid/'+list.openid+'">测试&nbsp;<i class="fa fa-angle-right" aria-hidden="true"></i></a>' +
                        '<a class="alllogss" href="/DDDeducation/public/index.php/home/User/sign/openid/'+list.openid+'">签到&nbsp;<i class="fa fa-angle-right" aria-hidden="true"></i></a>'+
                        '<a class="alllogsss" href="/DDDeducation/public/index.php/home/Homework/index/openid/'+list.openid+'">作业&nbsp;<i class="fa fa-angle-right" aria-hidden="true"></i></a>'+
                        '</div>' +
                        '<div style="color: #999;font-size: 1.3rem;padding: 6vw 0 6vw 4vw;">' +
                        '<span style="float: left;margin-top: -2.5vw;">今日完成：【签到】';
                if(list.is_sign == 1){
                    html+='<span style="color: green">√</span> ';
                }else{
                    html+='<span style="color: red">×</span> ';
                }
                html+='【总结】';
                if(list.is_summary == 1){
                    html+='<span style="color: green">√</span> ';
                }else{
                    html+='<span style="color: red">×</span> ';
                }
                html+='【测试】';
                if(list.is_test == 1){
                    html+='<span style="color: green">√</span> ';
                }else{
                    html+='<span style="color: red">×</span> ';
                }
                html+='【作业】';
                if(list.is_homework == 1){
                    html+='<span style="color: green">√</span> ';
                }else{
                    html+='<span style="color: red">×</span> ';
                }
                html+='</span>' +
                        '</div>' +
                        '</li></ul>';
            }
        }
        $(".result_box").append(html);
    }

    //点击进入输入框函数
    function onInput() {
        $(".searchBox").off('click').on('click',function(){
            $(".search").addClass('isClick');
            $(this).off('click').find('.searchInput').focus();
            $('.main').addClass('hidden');
        })
    }
    //关闭输入框函数
    function offInput(){
        $(".search").removeClass("isClick");
        $('.main').removeClass('hidden');
        $(".result_box").addClass('hidden');
        $(".onloading").addClass('hidden');
    }

    //关闭分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>

{/block}